﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BooksManagement
{
    public partial class Registered : Form
    {
        public Registered()
        {
            InitializeComponent();
        }



         Form1 form1 = new Form1();

        //注册条件
        private void button1_Click(object sender, EventArgs e)
        {
            var uase = textBox1.Text;
            var pwd = textBox2.Text;
            var redPwd = textBox3.Text;

            var shaUase = !string.IsNullOrEmpty(uase);
            var shaPwd = !string.IsNullOrEmpty(pwd);
            var shaPwds = pwd == redPwd;



            var sql = string.Format("select* from Users where Useername = '{0}' and Password = '{1}'", uase, pwd);
            var dt = Means.GetTheData(sql);

            if (dt.Rows.Count == 1)
            {
                MessageBox.Show("用户名重复！请重新输入！", "提示");
              
            }
            else
            {
                if (shaUase && shaPwd && shaPwds)
                {
                    MessageBox.Show("注册成功", "提示");
                    var sqls = string.Format("insert into Users(Useername,Password) values('{0}','{1}');", uase, pwd);
                    var res = Means.AddorEditOrDeleteSave(sqls);
                    this.Close();
                    form1.Show();

                }
                else
                {
                    MessageBox.Show("注册失败", "提示");
                }
            }






            



        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            form1.Show();
        }
    }
}
